/**
 * 
 */
package com.magus.project.yddemo.service;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.magus.framework.core.repository.BaseRepository;
import com.magus.framework.core.service.BaseService;
import com.magus.framework.system.entity.Company;
import com.magus.project.yddemo.entity.IndicatorPackage;
import com.magus.project.yddemo.repository.IndicatorPackageRepository;
import com.magus.project.yddemo.vobean.IndicatorPackageVoBean;

/**
 * @author wenyu.han
 * @date 2018-01-22 13:07:03
 */
@Service
@Transactional(readOnly = true)
public class IndicatorPackageService extends BaseService<IndicatorPackage, String> {

	@Autowired
	private IndicatorPackageRepository indicatorPackageRepository;
	
	@Override
	protected BaseRepository<IndicatorPackage, String> getBaseRepository() {
		return indicatorPackageRepository;
	}
	
	public List<IndicatorPackageVoBean> findVoBeanAllByCompany(Company company) {
		List<IndicatorPackage> list = indicatorPackageRepository.findAllByCompany(company);
		List<IndicatorPackageVoBean> collect = list.stream().map(temp->{
			IndicatorPackageVoBean voBean = new IndicatorPackageVoBean();
			voBean.setId(temp.getId());
			voBean.setName(temp.getName());
			voBean.setDimension(temp.getDimension());
			voBean.setText(temp.getName());
			return voBean;
		}).collect(Collectors.toList());
		return collect;
	}

}
